package P1.shuangzhizhen;

import java.util.Scanner;

/**
 * @Date : 2023-02-28
 * @Description:数组元素的目标和
 * 暴力
 * for(i=0;i<n;i++){
 *     for(j=0;j<m;j++)
 *     if(Ai+Bj=X)
 *     输出
 * }
 *
 * 单调性
 * for(i=0;i<n;i++0){
 * while(j>=0&&Ai+Bj>=X) j--;
 *     Ai+Bj>=x j最小
 *     }
 */
public class GoalSum {
    public static void main(String[] args) {
        int [] a=new int [100010],b=new int[100010];
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();

        for (int i = 0; i < n; i++) {
                a[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
                b[i]=sc.nextInt();
        }
        for (int i = 0,j=m-1; i < n; i++) {
            while(j>0&&a[i]+b[j]>x) j--;
            if(a[i]+b[j]==x) System.out.println(i+" "+j+"\n");
        }
    }
}
